﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DBHelper;
using BusinessLayer.RegInfo.Entities;
using System.Data.SqlClient;
using System.Data;


namespace BusinessLayer.RegInfo
{
    public class MarketingCategoryBL
    {
        public MarketingCategory GetByCode(string code)
        {
            var adapter = new BaseDAO(DbConfig.DbRegInfoConnectionString);
            adapter.AddParameter("@Code", code);
            var list = adapter.GetList<MarketingCategory>(Common.Constants.StoredProcedures.GetMarketingCategoryByCode,
                                                          CommandType.StoredProcedure, CustomConnectionState.CloseOnExit);
                        
            return list.FirstOrDefault();
        }
        public MarketingCategory GetByID(int id)
        {
            var adapter = new BaseDAO(DbConfig.DbRegInfoConnectionString);
            adapter.AddParameter("@CategoryID", id);
            var list = adapter.GetList<MarketingCategory>(Common.Constants.StoredProcedures.GetMarketingCategoryByID,
                                                          CommandType.StoredProcedure, CustomConnectionState.CloseOnExit);
            return list.FirstOrDefault();
        }
        public List<MarketingCategory> GetAll()
        {
            var adapter = new BaseDAO(DbConfig.DbRegInfoConnectionString);
            return adapter.GetList<MarketingCategory>(Common.Constants.StoredProcedures.GetAllMarketingCategories,
                                                      CommandType.StoredProcedure, CustomConnectionState.CloseOnExit);
        }
        
    }
}
